package com.service.impl;

import com.entity.PageBean;
import com.entity.PurOrder;
import com.entity.UnloadGoods;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.PurNoteMapper;
import com.mapper.PurOrderMapper;
import com.service.PurNoteService;
import com.service.PurOrderService;
import com.vo.PurOrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PurNoteServiceImpl implements PurNoteService {
    @Autowired
    private PurNoteMapper purNoteMapper;

    //列出入库单
    @Override
    public PageBean<PurOrder> getNoteList(Integer pageIndex, Integer pageSize, PurOrderVO purOrderVO) {
        PageHelper.startPage(pageIndex, pageSize);
        List<PurOrder> list= purNoteMapper.selectNoteList(purOrderVO);
        PageInfo<PurOrder> pageInfo = new PageInfo<>(list);
        PageBean<PurOrder> pageBean = new PageBean<>(
                pageIndex,//第几页
                pageSize,//每页显示的条数
                pageInfo.getPages(),//总页数
                (int)pageInfo.getTotal(),//数据总条数
                pageInfo.getList()//当前页的数据集合
        );
        return pageBean;
    }

    @Override
    public void updateNotestatusByoid(int oid) {
        purNoteMapper.updateNotestatusByoid(oid);
    }
    @Override
    public void modifyStoragedByOid(int oid) {
        purNoteMapper.updateStoragedByOid(oid);
    }

    @Override
    public void addUnloadGoods(UnloadGoods unloadGoods) {
        purNoteMapper.insertUnloadGoods(unloadGoods);
    }


    @Override
    public void removeNoteByOid(int oid) {
        purNoteMapper.cancleNoteByOid(oid);
    }



}
